home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2003 February / Windows News Numéro 107 février 2003.iso / Rédaction / Hotline / minuscules.vbs
Encoding:
Text File  |  2002-12-12  |  1.5 KB  |  50 lines

  1. '-----------------------------------------------------
  2. ' Renommage en minuscule des fichiers et dossiers
  3. ' d'un rΘpertoire 
  4. ' Auto-installable (par exΘcution sans paramΦtres)
  5. ' JC BELLAMY ⌐ 2002
  6. '-----------------------------------------------------
  7. Dim shell, args, fso, folder, collfic,curfic
  8. Set args = Wscript.Arguments
  9. Set shell = WScript.CreateObject("WScript.Shell")
  10. Set fso = WScript.CreateObject("Scripting.FileSystemObject")
  11. If args.count=0 Then 
  12. ' Auto-installation
  13. Script=Wscript.ScriptFullName
  14. Key="HKEY_CLASSES_ROOT\Folder\shell\Lowercase\"
  15. shell.RegWrite Key,"Renommage des fichiers en minuscules"
  16. Command="cscript """ & Script & """ ""%1"""
  17. shell.RegWrite Key & "command\",Command
  18. MsgBox "Script "& Script &" installΘ", vbInformation, "Renommage de fichiers"
  19. wscript.quit
  20. end if
  21. curdir=args(0)
  22. If not fso.FolderExists(curdir) Then
  23. wscript.echo "RΘpertoire inexistant"
  24. wscript.quit
  25. End If
  26. set folder=fso.GetFolder(curdir) 
  27. set collfic=folder.Files 
  28. tempname="xxxxx.xxx"
  29. nfic=collfic.count
  30. wscript.echo nfic & " fichiers"
  31. dim fic()
  32. redim fic(nfic+1)
  33. n=0
  34. For each curfic in collfic
  35. n=n+1
  36. fic(n)=curfic.Name
  37. next
  38. If right(curdir,1)<>"\" Then curdir=curdir & "\"
  39.  
  40. For i = 1 To nfic
  41. oldname=fic(i)
  42. set curfic=fso.GetFile(curdir & oldname) 
  43. newname=lcase(oldname)
  44. curfic.Name=tempname
  45. curfic.Name=newname
  46. wscript.echo i & " : " & oldname & " renommΘ en " & newname
  47. Next
  48.  
  49. MsgBox nfic & " fichiers renommΘs",,"Renommage en minuscules dans " & Curdir
  50.